// decorators/main
$(function() {
	$('#contextChangerSelect').change(function() {
		$('#contextChangerForm').submit();
	});
	
	var defaultLanguagePreviousValue = $("#defaultLanguageId").val();
	$("input[value='" + defaultLanguagePreviousValue + "']").prop("checked",true).prop("disabled",true);

	$("#defaultLanguageId").change(function(){
		$("input[value='" + defaultLanguagePreviousValue + "']").prop("disabled",false);
		$("input[value='" + this.value + "']").prop("checked",true).prop("disabled",true);
		defaultLanguagePreviousValue = this.value;
	});	
});

function updateSelectList(defaultPageSize){
	var tmp = $("#listPageSizeOptionsId").val().replace(/ /g,"").split(",");
	var selected = $("#defaultPageSizeId option:selected").text();
	var markAsSelected = true;
	
	if(!selected){
		selected = defaultPageSize;
	}
 
	$("#defaultPageSizeId option").remove();
	
	$.each(tmp,function(i,item){
		if(selected!=item){
			markAsSelected = false;
		} else {
			markAsSelected = true;
		}
		if(Math.floor(item)==item && $.isNumeric(item)){
			$("#defaultPageSizeId").append(new Option(item,item,markAsSelected,markAsSelected));
		}
	});
};
